<?php
class M_feedback extends CI_Model {

	public function add_feedback($customer, $contact, $email, $message){
		$data['customer'] = $customer;
		$data['contact'] = $contact;
		$data['email'] = $email;
		$data['message'] = $message;
		$data['sent'] = NOW;
		$q = $this->db->insert('feedback', $data);
		return $this->db->affected_rows() > 0 ? TRUE : FALSE;
	}
	
	public function getFeedbacks(){
		$q = $this->db->get('feedback');	
		return $q->num_rows() >= 1 ? $q->result() : FALSE;
	}
	
	public function getFeedback($id){
		$q = $this->db->get_where('feedback', array('id' => $id));	
		return $q->num_rows() >= 1 ? $q->row() : FALSE;
	}
		
	
	public function setMessage($id){
		$this->db->where('id', $id)->update('feedback', array('replied' => 1));
		
	}
}
?>